/**
 * 
 */
package com.edocbase.desktop.plugins.mdiary;

import java.util.HashMap;
import java.util.Map;

import com.edocbase.desktop.lightweight.widgets.ITabFolderListener;
import com.edocbase.desktop.lightweight.widgets.TabItem;

/**
 * @author X61
 *
 */
public class ToolButtonObserver implements ITabFolderListener{
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
		.getLogger(ToolButtonObserver.class);
	private MDiaryUI diaryUI = null;
	private ToolButtonManager buttonManager = null;
	private Map<String, ITabItemButtonObserver> observerCache = new HashMap<String, ITabItemButtonObserver>();
	public ToolButtonObserver(MDiaryUI diaryUI, ToolButtonManager buttonManager) {
		super();
		this.diaryUI = diaryUI;
		this.buttonManager = buttonManager;
	}
	public void addItemTypeObserver(String itmeType,ITabItemButtonObserver buttonObserver){
		if (observerCache.containsKey(itmeType)){
			return;
		}
		observerCache.put(itmeType,buttonObserver);
	}
	public boolean containsItemType(String type){
		return observerCache.containsKey(type);
	}
	@Override
	public void activeTab(TabItem item) {
		if (logger.isDebugEnabled()) {
			logger.debug("active " + item);
		}
//		String itemType = item.getItemType();
//		if (observerCache.containsKey(itemType)){
//			ITabItemButtonObserver observer = observerCache.get(itemType);
//			observer.active(item, buttonManager);
//		}
	}
	@Override
	public void deactiveTab(TabItem item) {
		if (logger.isDebugEnabled()) {
			logger.debug("deactive " + item);
		}
//		String itemType = item.getItemType();
//		if (observerCache.containsKey(itemType)){
//			ITabItemButtonObserver observer = observerCache.get(itemType);
//			observer.deactive(item, buttonManager);
//		}
	}
	@Override
	public void closeTab(TabItem item) {
		
	}
	@Override
	public boolean closeBefore(TabItem tabItem) {
		return true;
	}
	
}
